package shengchanxiaofeizhe;

public class Producter implements Runnable{
    @Override
    public void run() {
        while (true){
            WareHouse.lock.lock();

            if(WareHouse.mark){
                // 如果有包子
                try {
                    WareHouse.producer.await();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }else{
                System.out.println("生产者,创建包子... ");
                // 创建包子
                WareHouse.mark = true;
//                修改mark
                // 唤醒 消费者线程
                WareHouse.consumer.signal();
            }

            WareHouse.lock.unlock();
        }
    }
}
